package com.xkcoding.orm.mybatis.controller;

import com.xkcoding.orm.mybatis.entity.Co;
import com.xkcoding.orm.mybatis.entity.Dz;
import com.xkcoding.orm.mybatis.entity.Gd;
import com.xkcoding.orm.mybatis.entity.Hk;
import com.xkcoding.orm.mybatis.mapper.DzMapper;
import com.xkcoding.orm.mybatis.mapper.GdMapper;
import com.xkcoding.orm.mybatis.mapper.HkMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class DzController {

    @Autowired
    DzMapper dzMapper;
    @Autowired
    GdMapper gdMapper;
    @Autowired
    HkMapper hkMapper;

    @GetMapping("dz1")
    Object hk1(){
        List<Dz> dzList = dzMapper.selectGjAndPh();

        return dzList;
    }

    @GetMapping("dz2")
    Object hk2(){
        List<Dz> dzList = dzMapper.selectGjAndPhXml();

        return dzList;
    }

    @GetMapping("dz3")
    Object hk3(){
        List<Dz> dz = dzMapper.selectGjAndPhXml();
        List<Gd> gd = gdMapper.selectGjAndPh();
        List<Hk> hk = hkMapper.selectGjAndPh();

        ArrayList<Co> dzCo = new ArrayList<>();
        dzCo.addAll(dz);
        ArrayList<Co> gdCo = new ArrayList<>();
        gdCo.addAll(gd);
        ArrayList<Co> hkCo = new ArrayList<>();
        hkCo.addAll(hk);

        dzCo.addAll(gdCo);
        dzCo.addAll(hkCo);


        return dzCo;
    }
}
